Skip to content

Equality checks for structures#318

Merged
attipaci merged 12 commits into
mainfrom
no-memcmp-tests
May 11, 2026
Merged

Equality checks for structures#318
attipaci merged 12 commits into
mainfrom
no-memcmp-tests

Conversation

@attipaci
Copy link
Copy Markdown
Collaborator

@attipaci attipaci commented May 8, 2026

Using memcmp() to compare structures can be problematic, because of the padding between fields. The initializer is not guaranteed to set the padded areas to 0 (even if it usually does). When it does not, two structures may have identical fields bit-for-bit, but memcmp() will report them as differing because of the different uninitialized padding.

To resolve:

  • Add novas_equals_[...]() functions to the C99 API, and use these to perform comparisons between structures with typical 'sane' tolerances.
  • Add complete testing of the new struct comparison methods.
  • Add equals(), operator==() and operator!=() methods to more C++ classes, using the new C99 comparisons.
  • Add tests for new C++ methods.

@attipaci attipaci added this to the 1.7.0 milestone May 8, 2026
@attipaci attipaci self-assigned this May 8, 2026
@attipaci attipaci added the enhancement New feature or request label May 8, 2026
@attipaci attipaci linked an issue May 8, 2026 that may be closed by this pull request
@attipaci attipaci force-pushed the no-memcmp-tests branch from 8a83e58 to 8a26e6f Compare May 8, 2026 07:20
@coveralls
Copy link
Copy Markdown

coveralls commented May 8, 2026

Coverage Report for CI Build 25658801931

Coverage increased (+0.02%) to 99.142%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 252 of 252 lines across 7 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 9327
Covered Lines: 9247
Line Coverage: 99.14%
Coverage Strength: 40144.58 hits per line

💛 - Coveralls

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@attipaci attipaci force-pushed the no-memcmp-tests branch 7 times, most recently from bd9c3a3 to f9037bb Compare May 8, 2026 18:25
@attipaci attipaci changed the title Avoid memcmp() in tests Avoid memcmp() in tests and new C++ comparison methods. May 8, 2026
@attipaci attipaci force-pushed the no-memcmp-tests branch 3 times, most recently from 8045ce9 to 5f86712 Compare May 8, 2026 19:34
@attipaci attipaci marked this pull request as ready for review May 8, 2026 19:34
@attipaci attipaci force-pushed the no-memcmp-tests branch 6 times, most recently from 9d4b436 to 521fd57 Compare May 9, 2026 09:25
@attipaci attipaci changed the title Avoid memcmp() in tests and new C++ comparison methods. Avoid memcmp() in tests and new equality checks May 9, 2026
@attipaci attipaci changed the title Avoid memcmp() in tests and new equality checks Equality checking for structures May 10, 2026
@attipaci attipaci force-pushed the no-memcmp-tests branch 2 times, most recently from c4084a0 to 8e7a5da Compare May 10, 2026 19:46
@attipaci attipaci changed the title Equality checking for structures Equality checks for structures May 10, 2026
@attipaci attipaci merged commit 7ffe7d3 into main May 11, 2026
28 checks passed
@attipaci attipaci deleted the no-memcmp-tests branch May 11, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't use memcmp() to check for identical structures in tests

2 participants